﻿using System;
using System.Collections.Generic;
using UnityEngine;
using VoxelBlock;using Vector3Int = VoxelBlock.Vector3Int;
using VoxelBlock.VoxelBlock3D;

public abstract class AVoxelToMesh
{

    public AVoxelToMesh()
    {
        VoxelMetadata3D.InstanceGet();
    }

    /// <summary>
    /// 直接获得Mesh数据和图片数据
    /// </summary>
    /// <param name="voxelDatas"></param>
    /// <param name="texture"></param>
    /// <returns></returns>
    public virtual MyMesh GetMeshOrTexture(byte[] voxelDatas, out MyTexture2D texture, Vector3 localAnchor)
    { texture = new MyTexture2D(); return new MyMesh(); }

    /// <summary>
    /// 添加一个voxel数据，并将面的数据添加到图片缓冲区，获得顶点数据
    /// </summary>
    /// <param name="voxelDatas">voxel数据</param>
    /// <returns>顶点数据</returns>
    public virtual Vector3[] GetVertices(byte[] voxelDatas, Vector3 localAnchor) { return null; }

    /// <summary>
    /// 添加一张图片到图片缓冲区
    /// </summary>
    /// <param name="texture"></param>
    public virtual void AddTexture(Texture2D texture) { }

    /// <summary>
    /// 添加一张图片到图片缓冲区
    /// </summary>
    /// <param name="texture"></param>
    public virtual void AddTexture(MyTexture2D texture) { }

    /// <summary>
    /// 合并所有图片缓冲区的数据 ， 并获得三角面和UV信息
    /// </summary>
    /// <returns></returns>
    public virtual MyTexture2D Over(out int[] triangles, out Vector2[] uv)
    { triangles = null; uv = null; return new MyTexture2D(); }

}
